package com.shareinfo.auto.main;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.shareinfo.auto.service.AutoBuildService;
import com.shareinfo.auto.vo.ConfigureDatabase;
import com.shareinfo.auto.vo.ConfigureInit;
import com.shareinfo.auto.vo.ConfigureTemplate;
import com.shareinfo.auto.vo.ResultInfo;
import com.shareinfo.base.common.file.FileUtil;

/**
 * 
 * @author Administrator
 *
 */
public class Template5HbltQdpt {
	

	public static void main(String[] args) {
		ApplicationContext context = new ClassPathXmlApplicationContext("spring/applicationContext-*.xml");
		AutoBuildService autoBuildService = (AutoBuildService) context.getBean("autoBuildService");
		ResultInfo resultInfo =null;
		
		String[][] table={
			{"","","","",""}	
			//,{"com.shareinfo.mobile","TAccountInfo","T_AccountInfo","账号信息","/mobile"}
			//,{"com.shareinfo.mobile","TAccountClass","T_Account_Class","账号可见分类","/mobile"}
			//,{"com.shareinfo.mobile","TProductClass","t_product_class","产品分类","/mobile"}
			//,{"com.shareinfo.mobile","TProductAccount","T_PRODUCT_ACCOUNT","账号产品对应信息","/mobile"}
			//,{"com.shareinfo.mobile","TProduct","T_PRODUCT","产品信息","/mobile"}
			,{"com.shareinfo.mobile","TSmsVerify","T_SMS_VERIFY","短信验证码","/mobile"}
		};
		
		ConfigureInit conf = new ConfigureInit();
		conf.setConfigureTemplate(getConfigureTemplate());
		conf.setConfigureDatabase(getConfigureDatabase());

		for (int i = 0; i < table.length; i++) {
			if("".equals(table[i][0]))
				continue;
			conf.setPackageName(table[i][0]);
			conf.setClassName(table[i][1]);
			conf.setTableName(table[i][2].toUpperCase());
			conf.setComments(table[i][3]);
			conf.setUrlPath(table[i][4]);
			
			resultInfo = autoBuildService.run(conf);
			System.out.println(resultInfo);
		}
	}

	// 获取配置模板
	public static ConfigureTemplate getConfigureTemplate() {
		ConfigureTemplate configureTemplate = new ConfigureTemplate();
		configureTemplate.setTemplateId("5");
		configureTemplate.setPath("H:/jobCode/git/hpAutoBuild/auto/src/main/webapp/sysTemplate/5");
		configureTemplate.setOutPath("D:/output");
		if(true){
			new FileUtil().deleteDirectory(configureTemplate.getOutPath());
		}
		return configureTemplate;
	}

	// 获取模板数据库
	public static ConfigureDatabase getConfigureDatabase() {
		ConfigureDatabase configureDatabase = new ConfigureDatabase();
		configureDatabase.setDriver("oracle.jdbc.driver.OracleDriver");
		configureDatabase.setUrl("jdbc:oracle:thin:@192.168.18.101:1521:orcl");
		configureDatabase.setUsername("HBIMPGW");
		configureDatabase.setPassword("HBIMPGW");
		configureDatabase.setSchema("HBIMPGW".toUpperCase());
		configureDatabase.setCatalog(null);
		return configureDatabase;
	}
}
